/**
 * Created by Administrator on 2018/4/17.
 */
/**
 * 获取岗位树
 * @param isOpen 是否打开节点
 * @param isDataScope 是否查询数据权限 false 不查询
 * @param isUser 是否有用户节点
 * @returns {*}
 */
function getPositionTree(isOpen, isUser, isDataScope) {
    if(isDataScope == undefined){
        isDataScope = true;
    }
    var data;
    $.ajax({
        url: BASE_PATH + '/oa/api/getAllPositionAndUserTree?isDataScope=' + isDataScope + '&isUser=' + isUser,
        async: false,
        xhrFields: {withCredentials: true},
        success: function (res) {
            data = res;
            if (isOpen) {
                $(data).each(function (index, node) {
                    node.open = true;
                })
            }
        },
        fail: function (res) {
        }
    });
    return data;
}
/**
 * 获取部门树
 * @param isOpen 是否打开节点
 * @param isDataScope 是否查询数据权限 false 不查询
 * @param isUser 是否有用户节点
 * @returns {*}
 */
function getOrganizationTree(isOpen, isUser, isDataScope) {
    if(isDataScope == undefined){
        isDataScope = true;
    }
    var data;
    $.ajax({
        url: BASE_PATH + '/oa/api/selectUpmsOrganizationAndUserTree?isDataScope=' + isDataScope + '&isUser=' + isUser,
        async: false,
        xhrFields: {withCredentials: true},
        success: function (res) {
            data = res;
            if (isOpen) {
                $(data).each(function (index, node) {
                    node.open = true;
                })
            }
        },
        fail: function (res) {

        }
    });
    return data;
}
function sizeFormat(bSize) {
    if (bSize == undefined) {
        return "";
    }
    var size;
    var kb = 1024;
    var mb = kb * 1024;
    var gb = mb * 1024;
    if (bSize > kb && bSize < mb) {
        size = (bSize / kb).toFixed(2) + "KB";
    } else if (bSize > mb && bSize < gb) {
        size = (bSize / mb).toFixed(2) + "MB";
    } else if (bSize > gb) {
        size = (bSize / gb).toFixed(2) + "GB"
    } else {
        size = bSize + "B";
    }
    return size;
}